#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

char* func(char* str1, char* str2,char*str3,int*num,char*arr4)
{
	char* p;
	char* ret1;
	char* ret2;
	p = str1; int j = 0; int i = 0;
	while (*p != '\0')
	{
 		ret1 = p;
		ret2 = p + 1;
		while(*(ret2)!='\0')
		{
			ret2++;
			while (*ret1 != *ret2 && *(ret2) != '\0')
			{
				ret2++;
			}
			break;
		}
		i = ret2 - ret1;
		if (i > j)
		{
			memcpy(str2, p, i);
			strcpy(str3, ret2);
			char* s = strstr(str3, str2);
			if (s != NULL)
			{
				strcpy(arr4,str2); j = i; *num = i;
			}
			else
			{
				i = j;
			}
		}
		else if (i == j)
		{
			*num = i;
			strcpy(str3, ret2);
			int k=strcmp(str2, str3);
			if (k >=0)
			{
				strcpy(arr4,str2);
			}
			if (k < 0)
			{
				strcpy(arr4,str3);
			}
		}
		p++;
	}
	return arr4;
}
int main()
{
	char arr1[30];
	scanf("%s", arr1);
	char arr2[30] = { 0 };
	char arr3[30] = { 0 };
	char arr4[20] = { 0 };
	int num = 0;
	char*result=func(arr1, arr2,arr3,&num,arr4);
	printf("%s\n%d", result, num);
	return 0;
}